package vue;

import modele.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

@SuppressWarnings("serial")
public class RechercheArbreDecision extends JPanel implements ActionListener
{
	private JButton rechercheArbreDecision = new JButton("START");
	private JButton clear = new JButton("CLEAR");

	public RechercheArbreDecision()
	{
		add(clear, BorderLayout.WEST);
		add(rechercheArbreDecision, BorderLayout.CENTER);
		clear.addActionListener(this);
		rechercheArbreDecision.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == rechercheArbreDecision)
		{
			AfficheArbreDecision.reset();
			long start = System.currentTimeMillis();
			ArbreDecision.loadFichier();
			long start2 = System.currentTimeMillis();
			Affichage.afficher(("durée chargement fichier : " + ((float) (start2 - start)) / 1000 + "s"));
			
			
			/*
			// GrapheClique.progressBar.setClique(GrapheClique.getClique());
			Thread th = new Thread(new Runnable()
			{
				@Override
				public void run()
				{
					
					Thread th = new Thread(new Runnable()
					{
						@Override
						public void run()
						{
							while (GrapheClique.getClique().isRunning())
							{
								GrapheClique.progressBar.setValue(GrapheClique.getClique().getCpt());
							}
							GrapheClique.progressBar.setValue(GrapheClique.progressBar.getMaximum());
						}
					});
					th.start();
					GrapheClique.getClique().lancerRecherche();
				}
			});
			th.start();*/

		} else if (e.getSource() == clear)
		{
			Affichage.reset();
		}
	}
}

